/*

class Solution {
public:
    ListNode* Merge2(ListNode* pHead1, ListNode* pHead2)
    {
        if (pHead1 == nullptr)
            return pHead2;
        if (pHead2 == nullptr)
            return pHead1;
        ListNode* newnode = new ListNode(0), * tail = newnode;
        while (pHead1 && pHead2)
        {
            if (pHead1->val <= pHead2->val)
            {
                tail->next = pHead1;
                pHead1 = pHead1->next;
            }
            else
            {
                tail->next = pHead2;
                pHead2 = pHead2->next;
            }
            tail = tail->next;
        }
        if (pHead1)
            tail->next = pHead1;
        else
            tail->next = pHead2;

        return newnode->next;
    }

    ListNode* divideMerge(vector<ListNode*>& lists, int left, int right)
    {
        if (left > right)
            return nullptr;
        else if (left == right)
            return lists[left];

        int mid = (left + right) / 2;
        return Merge2(divideMerge(lists, left, mid), divideMerge(lists, mid + 1, right));
    }

    ListNode* mergeKLists(vector<ListNode*>& lists) {
        // write code here
        return divideMerge(lists, 0, lists.size() - 1);
    }
};


*/